/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sbbs.secret.dao;

import javax.ejb.EJB;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.jboss.shrinkwrap.api.asset.EmptyAsset.INSTANCE;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sbbs.secret.dao.impl.SecretUserDaoImpl;
import org.sbbs.secret.entity.SecretUser;

/**
 *
 * @author Mr.fdc <fdc_messenger@126.com>
 */
@RunWith(Arquillian.class)
public class SecretUserDaoIT {

    @EJB
    SecretUserDao dao;

    @Deployment
    public static Archive<?> createDeployment() {
        JavaArchive jar = create(JavaArchive.class)
                .addPackage(SecretUserDao.class.getPackage())
                .addPackage(SecretUserDaoImpl.class.getPackage())
                .addAsManifestResource("META-INF/persistence.xml", "persistence.xml")
                .addAsManifestResource(INSTANCE, "beans.xml");
        return jar;
    }

    @Test
    public void testSomeMethod() {
        SecretUser user = new SecretUser();
        user.setEmail("fdc@sina.com");
        user.setMobile("13366528500");
        user.setPassWord("testPsw");
        user.setPubKey("testPUK");
        user.setSalt("testSalt");
        user.setUserName("userName");
        user = this.dao.save(user);
        Assert.assertNotNull(user.getId());

    }

}
